/**
 * 
 */
package com.elephantgreen.xml;

import java.util.Vector;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

import com.elephantgreen.common.ElephantgreenCommon;
import com.elephantgreen.common.Trucks;
import com.elephantgreen.util.Util;

/**
 * @author ABC
 * 
 */
public class TrucksXml extends ElephantgreenXmlHandler {

	/**
	 * @param fName
	 * @param parentNodeName
	 */
	public TrucksXml(String fName, String parentNodeName) {
		super(fName, parentNodeName);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.elephantgreen.persistance.ElephantgreenXmlHandler#getItems()
	 */
	@Override
	public Vector<ElephantgreenCommon> getItems() {


		Vector<ElephantgreenCommon> vTrucks = new Vector<ElephantgreenCommon>();

		for (int temp = 0; temp < getNodes().getLength(); temp++) {

			Node nNode = getNodes().item(temp);
			if (nNode.getNodeType() == Node.ELEMENT_NODE) {

				Element element = (Element) nNode;

				Trucks truck = new Trucks(
						Util.getTagValue("truckLicenseNumber", element),
						Util.getTagValue("comments", element),
						Util.getTagValue("active", element));

				vTrucks.add(truck);

			}
		}
		return vTrucks;
	}

}
